import { createSlice, PayloadAction } from '@reduxjs/toolkit'

interface UserStateType {
	nickname: string
	tags: UserAboutTagsType[]
	tel: string
	isLogin: boolean
}

interface UserAboutTagsType {
	"image": string,
	"title": string,
	"id": string
}

const initialState: UserStateType = {
	nickname: '',
	tags: [],
	tel: '',
	isLogin: false
}

const userSlice = createSlice({
	name: 'user',
	initialState,
	reducers: {
		loginSuccess(state, action: PayloadAction<UserStateType>) {
			state.isLogin = action.payload.isLogin
			state.tags = action.payload.tags
			state.tel = action.payload.tel
			state.nickname = action.payload.nickname
		}
	}
})

export default userSlice
export const { loginSuccess } = userSlice.actions